package com.jltx.storage.downloader;

/**
 * @author jltxseo
 * Created by junlintianxia on 2019/12/02.
 */
public class RequestResult<T> {

    public final String filePath;
    public final String url;
    public final int status;
    public final long total;
    public final long progress;

    public final T data;
    public final Throwable error;

    public RequestResult(String filePath, String url, int status) {
        this(filePath, url, status, 0, 0);
    }

    public RequestResult(String filePath, String url, int status, long total, long progress) {
        this.filePath = filePath;
        this.url = url;
        this.status = status;
        this.total = total;
        this.progress = progress;
        this.data = null;
        this.error = null;
    }

    public RequestResult(String filePath, String url, int status, long total, long progress, T data) {
        this.filePath = filePath;
        this.url = url;
        this.status = status;
        this.total = total;
        this.progress = progress;
        this.data = data;
        this.error = null;
    }

    public RequestResult(String filePath, String url, int status, long total, long progress, Throwable error) {
        this.filePath = filePath;
        this.url = url;
        this.status = status;
        this.total = total;
        this.progress = progress;
        this.data = null;
        this.error = error;
    }

    public RequestResult(String filePath, String url, int status, Throwable error) {
        this(filePath, url, status, 0, error);
    }


    public RequestResult(String filePath, String url, int status, long total, Throwable error) {
        this(filePath, url, status, total, 0, error);
    }

    @Override
    public String toString() {
        return "RequestResult{" +
                "filePath='" + filePath + '\'' +
                ", url='" + url + '\'' +
                ", status=" + status +
                ", total=" + total +
                ", progress=" + progress +
                '}';
    }
}
